<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="年度" prop="year">
          <el-date-picker
          v-model="queryParams.year"
          type="year"
          format="yyyy"
          value-format="yyyy"
          placeholder="选择种植年度">
          </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['waterDistribution:wrPlanDayIrr:export']"
          >导出</el-button>
      </el-form-item>
    </el-form>

    <div class="tb_title" v-html="tableTitle"></div>
      <div class="tb_dw" >单位：<span class="hj_cl_blue">m³</span></div>

    <el-table v-loading="loading" stripe :data="wrPlanDayIrrList" :header-cell-style="tableHeaderColor">
      <el-table-column label="断面名称" fixed="left" width="120" align="left" prop="crossNm" show-overflow-tooltip/>
      <!-- <el-table-column label="限额指标" fixed="left" align="center" prop="nxeWater" show-overflow-tooltip/> -->
      <el-table-column label="合计" fixed="left" align="center" prop="sum" show-overflow-tooltip/>
      <el-table-column label="春灌" align="center" show-overflow-tooltip>
          <el-table-column label="1月" align="center" prop="month01" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon011" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon012" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon013" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon014" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="2月" align="center" prop="month02" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon021" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon022" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon023" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon024" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="3月" align="center" prop="month03" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon031" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon032" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon033" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon034" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="4月" align="center" prop="month04" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon041" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon042" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon043" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon044" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
      </el-table-column>
      <el-table-column label="夏灌" align="center" show-overflow-tooltip>
          <el-table-column label="5月" align="center" prop="month05" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon051" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon052" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon053" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon054" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="6月" align="center" prop="month06" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon061" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon062" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon063" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon064" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="7月" align="center" prop="month07" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon071" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon072" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon073" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon074" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="8月" align="center" prop="month08" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon081" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon082" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon083" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon084" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
      </el-table-column>
      <el-table-column label="冬灌" align="center" show-overflow-tooltip>
          <el-table-column label="9月" align="center" prop="month09" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon091" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon092" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon093" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon094" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="10月" align="center" prop="month10" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon101" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon102" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon103" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon104" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="11月" align="center" prop="month11" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon111" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon112" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon113" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon114" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
          <el-table-column label="12月" align="center" prop="month12" show-overflow-tooltip>
              <!-- <el-table-column label="上旬" align="center" prop="mon121" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="中旬" align="center" prop="mon122" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="下旬" align="center" prop="mon123" show-overflow-tooltip>
              </el-table-column>
              <el-table-column label="小计" align="center" prop="mon124" show-overflow-tooltip>
              </el-table-column> -->
          </el-table-column>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { getCroVolYear } from "@/api/waterDistribution/wrPlanDayIrr";
export default {
  name: "WrPlanDayIrr",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 灌区用水日计划表格数据
      wrPlanDayIrrList: [],
      // 年份选择
      yearList: [],
      // 弹出层标题
      title: "",
      // 列表标题行内容
      tableTitle: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        year: null,
        chanCd:'CHA001000000000'
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询灌区用水日计划列表 */
    getList() {
      this.loading = true;
      if(this.queryParams.year == null) {
        var day = new Date();
        var nowYear = day.getFullYear().toString();
        this.queryParams.year = nowYear;
      }
      this.tableTitle = `富蕴县` + this.queryParams.year + `年1月—12月限额用水计划过程表`;
      getCroVolYear(this.queryParams).then(response => {
        // response.data.forEach(element => {
        //   for (const key in element) {
        //     const obj = element[key];
        //     if(obj == '0.00'){
        //       element[key] = ''
        //     }
        //   }
        // });
        this.wrPlanDayIrrList = response.data;
        // this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('distribute/WiGetvolM/export', {
        ...this.queryParams
      }, `富蕴县` + this.queryParams.year + `年1月—12月限额用水计划过程表.xlsx`)
    },
    /** 修改table header的背景色 */
    tableHeaderColor(row, rowIndex) {
      return 'background-color: #e6f4f8; font-weight: 700px !important;';
    },
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

    .tb_title{
        // width: 430px;
        text-align: center;
        margin: 5px auto;
        margin-bottom: 15px;
        font-weight: 700;
    }

    .tb_dw{
        font-size: 13px;
        position: absolute;
        top: 84px;
        right: 40px;
    }

    .hj_cl{
        font-weight: 700;
    }

    .hj_cl_blue {
        color: #1890ff !important;
        font-weight: 700;
    }

    .el-table__footer-wrapper tbody td.el-table__cell{
        font-weight: 700;
    }
    .el-table .el-table__footer-wrapper .cell{
        font-weight: 700;
    }

    .vue-treeselect__placeholder, .vue-treeselect__single-value {
        line-height: 30px;
    }

    .vue-treeselect {
        width: 215px;
        height: 30px;
        .vue-treeselect__control {
            height: 30px;
            .el-form-item--medium .el-form-item__content {
                line-height: 30px;
                .vue-treeselect__placeholder, .vue-treeselect__single-value {
                    line-height: 30px;
                }
            }
        }
    }

    .el-table th.gutter{
        display: table-cell!important;
    }

</style>
